package Classes;
public class Question {
    
    private String questionText;
    private String answer;
    private boolean testType;
    private String[] choices;
    private boolean[] selected;
    private boolean done;
    
    public Question(String questionText) {      // constructor for open-answer questions
        this.questionText = questionText;
        testType = false;
        answer = "";
        done = false;
    }
    
    public Question(String questionText,String[] choices) {     // constructor for test type questions
        this.questionText = questionText;
        testType = true;
        this.choices = choices;
        for(int choice=0; choice<choices.length; choice++) {    // setting no choice selected
            selected[choice] = false;
        }
        done = false;
    }
    
    public void setStudentAnswer(String answer) {
        this.answer = answer;
    }
    
    public String getStudentAnswer() {
        return answer;
    }
    
    public void addSelection(int choice) {
        selected[choice] = true;
    }
    
    public void removeSelection(int choice) {
        selected[choice] = false;
    }
    
    public boolean[] getSelected() {
        return selected;
    }
    
    public boolean isDone() {
        if(testType) {
            for(int choice=0; choice<choices.length; choice++) {
                if(selected[choice]) return true;
            }
            return false;
        } else {
            if(answer.equals("")) return false;
            return true;
        }
    }
}
